cmake_minimum_required(VERSION 3.14)
project(app LANGUAGES CXX)

# 配置C++标准与异常禁用
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

if(MSVC)
    add_compile_options(/EHa- /EHc- /Zc:throwingNew-)
else()
    add_compile_options(-fno-exceptions -fno-rtti -fsanitize=address)
    add_link_options(-fsanitize=address)
endif()

# 引入expected库
include(FetchContent)
FetchContent_Declare(
    tl-expected
    GIT_REPOSITORY https://gitee.com/wzzc-dev/expected.git
    GIT_TAG v1.1.0  # 使用最新稳定版本
)
set(EXPECTED_BUILD_TESTS OFF CACHE BOOL "Disable tests")
set(BUILD_TESTING OFF)
FetchContent_MakeAvailable(tl-expected)

# 项目结构配置
add_executable(${PROJECT_NAME}
    src/main.cpp
    # 其他源文件...
)

target_include_directories(${PROJECT_NAME} PRIVATE
    include/
    ${tl-expected_SOURCE_DIR}/include
)

target_link_libraries(${PROJECT_NAME} PRIVATE
    tl::expected  # 根据仓库实际导出目标调整
)

# 安装规则（可选）
install(TARGETS ${PROJECT_NAME} DESTINATION bin)